package com.acme.bankapp.domain.account;

import com.acme.bankapp.domain.exceptions.NotEnoughFundsException;


public class SavingAccount extends AbstractAccount {

	public SavingAccount(double amount) {
		super(amount);
	}

	@Override
	public void deposit(double amount) {
		validateAmount(amount);
		balance += amount;
	}

	@Override
	public void withdraw(double amount) throws NotEnoughFundsException {
		validateAmount(amount);
		if (balance > amount) {
			balance -= amount;
		} else {
			throw new NotEnoughFundsException();
		}
	}

	@Override
	public double maximumAmountToWithdraw() {
		return balance;
	}
}
